package AbstractFactory;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

abstract class SkinFactory {
    public abstract Button createButton();
    public abstract TextField createTextField();
    public abstract ComboBox createComboBox();
}

class SpringSkinFactory extends SkinFactory{
    @Override
    public Button createButton() {
        return new SpringButton();
    }

    @Override
    public ComboBox createComboBox() {
        return new SpringComboBox();
    }

    @Override
    public TextField createTextField() {
        return new SpringTextField();
    }
}

class SummerSkinFactory extends SkinFactory{
    @Override
    public Button createButton() {
        return new SummerButton();
    }

    @Override
    public ComboBox createComboBox() {
        return new SummerComboBox();
    }

    @Override
    public TextField createTextField() {
        return new SummerTextField();
    }
}

interface Button{
    void print();
}
interface ComboBox{
    void print();
}
interface TextField{
    void print();
}

class SpringButton implements Button{
    @Override
    public void print() {
        System.out.println("SpringButton");
    }
}
class SummerButton implements Button{
    @Override
    public void print() {
        System.out.println("SummerButton");
    }
}
class SpringComboBox implements ComboBox{
    @Override
    public void print() {
        System.out.println("SpringComboBox");
    }
}
class SummerComboBox implements ComboBox{
    @Override
    public void print() {
        System.out.println("SummerComboBox");
    }
}
class SpringTextField implements TextField{
    @Override
    public void print() {
        System.out.println("SpringTextField");
    }
}
class SummerTextField implements TextField{
    @Override
    public void print() {
        System.out.println("SummerTextField");
    }
}

class Client{
    public static void main(String[] args) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {
//        SpringSkinFactory spring = new SpringSkinFactory();
//        spring.createButton().print();
        Properties properties = new Properties();
        properties.load(new FileInputStream("./config.properties"));
        String factoryClassName = properties.getProperty("skin.factory");

        SkinFactory factory = (SkinFactory) Class.forName(factoryClassName).newInstance();
        factory.createButton().print();
    }
}

//git版本管理


